@@ -15,10 +15,11 @@ from paginator import pagination |
||
15 | 15 |
from TimeConvert import TimeConvert as tc |
16 | 16 |
|
17 | 17 |
from account.models import UserInfo |
18 |
+from api.encrypt_views import get_ciphertext |
|
18 | 19 |
from coupon.models import CouponInfo, UserCouponInfo |
19 | 20 |
from integral.models import SaleclerkSubmitLogInfo |
20 | 21 |
from logs.models import ComplementCodeLogInfo, MchInfoEncryptLogInfo |
21 |
-from mch.models import AdministratorInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo |
|
22 |
+from mch.models import AdministratorInfo, BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo |
|
22 | 23 |
from member.models import GoodsInfo, GoodsOrderInfo, MemberActivityGroupShareInfo, MemberActivityInfo |
23 | 24 |
from statistic.models import ConsumeModelSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo |
24 | 25 |
from utils.error.errno_utils import (AdministratorStatusCode, ComplementCodeStatusCode, ProductBrandStatusCode, |
@@ -1448,9 +1449,37 @@ def complement_code_audit(request): |
||
1448 | 1449 |
log.audit_status = audit_status |
1449 | 1450 |
log.save() |
1450 | 1451 |
|
1451 |
- # if log.audit_status == ComplementCodeLogInfo.AUDIT_PASS: |
|
1452 |
- # # TODO: Send template_message |
|
1453 |
- # pass |
|
1452 |
+ # 如果"审核通过" |
|
1453 |
+ if log.audit_status == ComplementCodeLogInfo.AUDIT_PASS: |
|
1454 |
+ # # TODO: Send template_message |
|
1455 |
+ try: |
|
1456 |
+ brand = BrandInfo.objects.get(brand_id=brand_id) |
|
1457 |
+ except BrandInfo.DoesNotExist: |
|
1458 |
+ brand = None |
|
1459 |
+ |
|
1460 |
+ try: |
|
1461 |
+ model = ModelInfo.objects.get(model_id=log.model_id) |
|
1462 |
+ except ModelInfo.DoesNotExist: |
|
1463 |
+ model = None |
|
1464 |
+ |
|
1465 |
+ # brand_id#model_id#distributor_id#sn#time |
|
1466 |
+ # AAAA#AAAAAA#AAAAA#AAAAAAAAAAAAAA#180224 |
|
1467 |
+ # brand_pk, model_pk, distributor_pk, sn, time = plaintext.split('#') |
|
1468 |
+ plaintext = '{}#{}#{}#{}#{}'.format( |
|
1469 |
+ brand.pk if brand else 0, |
|
1470 |
+ model.pk if model else 0, |
|
1471 |
+ 0, |
|
1472 |
+ log.sn, |
|
1473 |
+ tc.local_string(format='%Y%m%d')[2:], |
|
1474 |
+ ) |
|
1475 |
+ ciphertext = get_ciphertext(plaintext, admin_id, True) |
|
1476 |
+ |
|
1477 |
+ log.ciphertext = ciphertext |
|
1478 |
+ log.save() |
|
1479 |
+ |
|
1480 |
+ return response(data={ |
|
1481 |
+ 'ciphertext': ciphertext, |
|
1482 |
+ }) |
|
1454 | 1483 |
|
1455 | 1484 |
return response() |
1456 | 1485 |
|
@@ -35,12 +35,7 @@ CIPHER_PREFIX = { |
||
35 | 35 |
} |
36 | 36 |
|
37 | 37 |
|
38 |
-@logit(res=True) |
|
39 |
-def encrypt(request): |
|
40 |
- plaintext = request.POST.get('plaintext', '') |
|
41 |
- optor_id = request.POST.get('optor_id', '') |
|
42 |
- marketcode = request.POST.get('marketcode', '') |
|
43 |
- |
|
38 |
+def get_ciphertext(plaintext, optor_id, marketcode): |
|
44 | 39 |
# brand_id#model_id#distributor_id#sn#time |
45 | 40 |
# AAAA#AAAAAA#AAAAA#AAAAAAAAAAAAAA#180224 |
46 | 41 |
brand_pk, model_pk, distributor_pk, sn, time = plaintext.split('#') |
@@ -53,7 +48,7 @@ def encrypt(request): |
||
53 | 48 |
marketcode = MarketCodeInfo.objects.select_for_update().filter(has_used=False).first() |
54 | 49 |
|
55 | 50 |
if not marketcode: |
56 |
- return response(MarketCodeStatusCode.MARKET_CODE_NOT_FOUND) |
|
51 |
+ return '' |
|
57 | 52 |
|
58 | 53 |
marketcode.has_used = True |
59 | 54 |
marketcode.save() |
@@ -68,9 +63,7 @@ def encrypt(request): |
||
68 | 63 |
mieli.operator_id = optor_id |
69 | 64 |
mieli.save() |
70 | 65 |
|
71 |
- return response(200, data={ |
|
72 |
- 'ciphertext': mieli.code_url, |
|
73 |
- }) |
|
66 |
+ return mieli.code_url |
|
74 | 67 |
|
75 | 68 |
if created_at: |
76 | 69 |
alg = random.choice(CIPHER_ALGORITHM) |
@@ -93,12 +86,21 @@ def encrypt(request): |
||
93 | 86 |
mieli.operator_id = optor_id |
94 | 87 |
mieli.save() |
95 | 88 |
|
89 |
+ return u'{prefix}+{cipherlen}+{ciphertext}'.format( |
|
90 |
+ prefix=CIPHER_PREFIX.get(mieli.alg, ''), |
|
91 |
+ cipherlen=len(mieli.ciphertext), |
|
92 |
+ ciphertext=mieli.ciphertext, |
|
93 |
+ ) |
|
94 |
+ |
|
95 |
+ |
|
96 |
+@logit(res=True) |
|
97 |
+def encrypt(request): |
|
98 |
+ plaintext = request.POST.get('plaintext', '') |
|
99 |
+ optor_id = request.POST.get('optor_id', '') |
|
100 |
+ marketcode = request.POST.get('marketcode', '') |
|
101 |
+ |
|
96 | 102 |
return response(200, data={ |
97 |
- 'ciphertext': u'{prefix}+{cipherlen}+{ciphertext}'.format( |
|
98 |
- prefix=CIPHER_PREFIX.get(mieli.alg, ''), |
|
99 |
- cipherlen=len(mieli.ciphertext), |
|
100 |
- ciphertext=mieli.ciphertext, |
|
101 |
- ), |
|
103 |
+ 'ciphertext': get_ciphertext(plaintext, optor_id, marketcode), |
|
102 | 104 |
}) |
103 | 105 |
|
104 | 106 |
|
@@ -29,8 +29,8 @@ class MchSearchModelAndCameraLogInfoAdmin(admin.ModelAdmin): |
||
29 | 29 |
|
30 | 30 |
|
31 | 31 |
class ComplementCodeLogInfoAdmin(admin.ModelAdmin): |
32 |
- list_display = ('user_id', 'log_id', 'name', 'phone', 'model_id', 'model_name', 'sn', 'shot_image', 'invoice_image', 'audit_status', 'status', 'created_at', 'updated_at') |
|
33 |
- list_filter = ('model_id', 'status') |
|
32 |
+ list_display = ('user_id', 'log_id', 'name', 'phone', 'model_id', 'model_name', 'sn', 'shot_image', 'invoice_image', 'audit_status', 'ciphertext', 'is_contacted', 'status', 'created_at', 'updated_at') |
|
33 |
+ list_filter = ('model_id', 'audit_status', 'is_contacted', 'status') |
|
34 | 34 |
|
35 | 35 |
|
36 | 36 |
admin.site.register(MchInfoDecryptLogInfo, MchInfoDecryptLogInfoAdmin) |
@@ -0,0 +1,25 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.29 on 2021-01-07 06:38 |
|
3 |
+from __future__ import unicode_literals |
|
4 |
+ |
|
5 |
+from django.db import migrations, models |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class Migration(migrations.Migration): |
|
9 |
+ |
|
10 |
+ dependencies = [ |
|
11 |
+ ('logs', '0015_complementcodeloginfo_is_contacted'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AddField( |
|
16 |
+ model_name='complementcodeloginfo', |
|
17 |
+ name='ciphertext', |
|
18 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u5f85\u89e3\u5bc6\u5b57\u7b26\u4e32', max_length=64, null=True, verbose_name='ciphertext'), |
|
19 |
+ ), |
|
20 |
+ migrations.AlterField( |
|
21 |
+ model_name='complementcodeloginfo', |
|
22 |
+ name='audit_status', |
|
23 |
+ field=models.IntegerField(choices=[(0, '\u5f85\u5ba1\u6838'), (1, '\u5ba1\u6838\u901a\u8fc7'), (-1, '\u5ba1\u6838\u4e0d\u901a\u8fc7')], default=0, help_text='\u5ba1\u6838\u72b6\u6001', verbose_name='audit_status'), |
|
24 |
+ ), |
|
25 |
+ ] |
@@ -143,6 +143,8 @@ class ComplementCodeLogInfo(BaseModelMixin): |
||
143 | 143 |
|
144 | 144 |
audit_status = models.IntegerField(_(u'audit_status'), choices=AUDIT_STATUS_TUPLE, default=AUDIT_TODO, help_text=u'审核状态') |
145 | 145 |
|
146 |
+ ciphertext = models.CharField(_(u'ciphertext'), max_length=64, blank=True, null=True, help_text=u'待解密字符串', db_index=True) |
|
147 |
+ |
|
146 | 148 |
is_contacted = models.BooleanField(_(u'is_contacted'), default=False, help_text=u'是否已联系用户') |
147 | 149 |
|
148 | 150 |
class Meta: |